<%
    ServletContext context = this.getServletConfig().getServletContext();
	String path = request.getContextPath();
	String serverName = request.getScheme()+"://"+request.getServerName();
    //Host name of the Domino server.
    //Examples:
    //  http://domino.acme.com
    //  https://domino.acme.com
    //  (Do not end with a / character)
    String dominoLoginSiteURL = serverName;

    //Custom text for the login form.  Defined in web.xml.
    String bannerMessage = context.getInitParameter("BannerMessage") == null ? "Welcome" : context.getInitParameter("BannerMessage");
    String welcomeMessage = context.getInitParameter("WelcomeMessage") == null ? "Use your Domino User name and Password." : context.getInitParameter("WelcomeMessage");
    String imageURL = context.getInitParameter("ImageURL") == null || context.getInitParameter("ImageURL").equals("") ? "" : "<img src=\"" + context.getInitParameter("ImageURL") + "\" border=\"0\"/>";

    //Page requested by the user.
    //For example, when the user opens this form using http://tomcat.acme.com/login/?page=http://tomcat.acme.com/myapp?aaa=1&bbb=2&ccc=3
    //then the value for redirectTo will be http://tomcat.acme.com/myapp?aaa=1&bbb=2&ccc=3
    String queryString = request.getQueryString();
    String redirectTo;
    if( queryString == null ) {
        redirectTo = "/";
    } else {
        redirectTo = queryString.substring(queryString.indexOf("page=") + 5);
    }
    String server = dominoLoginSiteURL+"/names.nsf?Login";
%>

<html>
<head>
    <title>Sign In</title>
    <link rel="stylesheet" type="text/css" href="login.css"/>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="expires" content="-1"/>
</head>

<body onLoad="document.loginForm.username.focus();">
<form name="loginForm" action="dominoRedirector.nsf" method="post">
<br/><br/>
<table align="center" valign="center" border="1" width="500" cellspacing="0" cellpadding="0">
    <tr>
        <td>

        <table border="0" cellpadding="14" cellspacing="0" width="100%">
            <tr bgcolor="#9FA193">
                <td align="center"><strong><%= bannerMessage %></strong></td>
            </tr>
        </table>

        <br/>
        <br/>

        <table border="0" cellspacing="0" cellpadding="0" width="100%">
            <tr>
                <td>&nbsp;</td>
                <td align="center"><span class="bodyText"><%= welcomeMessage %></span></td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td align="center">
                    <br/>
                    <table width="100%" border="0" cellspacing="0" cellpadding="3">
                        <tr>
                            <td align="right"><span class="loginText">User name&nbsp;&nbsp;</span></td>
                            <td width="60%"><input type="text" name="username" size="25" maxlength="256" value=""/></td>
                        </tr>
                        <tr>
                            <td align="right" width="40%"><span class="loginText">Password&nbsp;&nbsp;</span></td>
                            <td width="60%"><input type="password" name="password" size="25" maxlength="256" value=""/></td>
                        </tr>
                        <tr>
                            <td align="right"></td>
                            <td width="60%">
                                <input type="submit" class="button" name="submit" value="Sign In"/>
                                <br/>
                            </td>
                        </tr>
                    </table>
                    <br/>
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td align="center">
                    <!-- add a picture here -->
                    <%= imageURL %>
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td align="left">
                    <p class="bodyText">
                    <!-- add helpful text here -->
                    </p>
                </td>
                <td>&nbsp;</td>
            </tr>
        </table>


        </td>
    </tr>
</table>

<input type="hidden" name="RedirectTo" value="<%= redirectTo %>"/>
<input type="hidden" name="server" value="<%= server %>"/>

</form>
</body>
</html>